<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>使用JavaScript的html测试</title>
    <script src="../js/one.js"></script>
</head>

<body>
    <p>
        JavaScript 能够直接写入 HTML 输出流中：
    </p>
    <script>
        <!--document应该就是当前文件-->
        document.write("<h1>This is a heading</h1>");
        document.write("<p>This is a paragraph.</p>");
    </script>
    <p>
        您只能在 HTML 输出流中使用 <strong>document.write</strong>。
如果您在文档已加载后使用它（比如在函数中），会覆盖整个文档。
    </p>

    <!--alert是JavaScript中的一个函数-->
    <button type="button" onclick="alert('Welcome!')">点击这里</button>

    <h1>我的第二段JavaScript</h1>
    <!--为标签指定了id值-->
    <p id="demo">
        JavaScript能改变html元素的内容
    </p>
    <script>
        <!--定义一个js的函数-->
        function myFunction()
        {
            var name = "Hello JavaScript!";
            x = document.getElementById('demo');
            x.style.color="#ff0000";
            x.innerHTML=name;
        }
    </script>
    <button type="button" onclick="myFunction()">点击这里</button>
    <br/>

    <script>
        <!--修改标签的属性的值-->
        function changeImage()
        {
            element = document.getElementById('myimage');
            if (element.src.match("bulbon"))
            {
                element.src = "../source/img/eg_bulboff.gif";
            }
            else
            {
                element.src = "../source/img/eg_bulbon.gif";
            }
        }
    </script>
    <img id="myimage" onclick="changeImage()" src="../source/img/eg_bulboff.gif">
    <p>点击灯泡来点亮或熄灭这站灯</p>

    <h1>这是第一个输入</h1>
    <p>请输入数字。如果输入值不是数字，浏览器会弹出提示框。</p>
    <input id="input_button" type="text">
    <script>
        <!--取出标签中输入，然后判断-->
        function check()
        {
            var x = document.getElementById("input_button").value;
            if (x == "" || isNaN(x))
            {
                alert("Not numeric");
            }
        }
    </script>
    <button type="button" onclick="check()">提交</button>

    <h1>小丸子</h1>
    <script>
        document.write("<p>骂了隔壁</p>")
    </script>
    <button type="button" onclick="print_function()">说什么</button>

    <br>
    <script>
        var i;
        var cars = new Array();
        cars[0] = "Audi";
        cars[1] = "BMW";
        cars[2] = 'Volvo';

        for (i = 0; i < cars.length; i++)
        {
            document.write(cars[i] + "<br>");
        }
    </script>

    <br>
    <script>
        var person = {
            firstname: "Bill",
            lastname: "Gates",
            id: 5566
        };

        document.write(person.lastname + "<br>");
        document.write(person.firstname + "<br>");
    </script>

    <br>
    <script>
        person = new Object();
        person.firstname = "xiao";
        person.lastname = "wanzi";
        person.age = 45;
        person.eyecolor = "blue";
        document.write(person.firstname + " is " + person.age + " years old.");
        document.write("<br>");
        var x = person.firstname.toUpperCase();
        document.write(x);
    </script>

    <br>
    <button onclick="ceo_wel('cheng', 'ceo')">程用学</button>

    <p>本例调用的函数会执行一个计算，然后返回结果：</p>
    <p id = "add"></p>
    <script>
        document.getElementById("add").innerHTML = add(5, 5);
    </script>

    <br>
    <script>
        <!--数字和字符串相加，结果将成为字符串-->
        var x = 5 + 5;
        document.write(x + "<br>");
        var y = "5" + "5";
        document.write(y + "<br>");
        var z = 5 + "5";
        document.write(z + "<br>");
        var t = "5" + 5;
        document.write(t + "<br>");
    </script>

    <br>
    <script>
        document.write(time_say(16))
    </script>

    <br>
    <script>
        document.write(day_name())
    </script>

    <br>
    <script>
        var person = {fname: "John", lname: "wanzi", age: 34};
        for (x in person)
        {
            document.write(person[x] + "<br>");
        }
    </script>

    <br>
    <script>
        var cars = ["BMW","Volvo","Saab","Ford"];
        list:
        {
            document.write(cars[0] + "<br>");
            document.write(cars[1] + "<br>");
            document.write(cars[2] + "<br>");
            break list;
            document.write(cars[3] + "<br>");
        }
    </script>

    <br>
    <input type="button" value="View Message" onclick="message()">

    <br>
    <h1>hallol</h1>
    <p>Please input a number between 5 and 10:</p>
    <input id="demo1" type="text">
    <button type="button" onclick="check()">Test Input</button>
    <p id="mess"></p>
</body>

</html>